@use './variables.scss' as *;

// 通用样式

// 页面布局
.page-container {
  min-height: 100vh;
  background-color: var(--bg-color);
}

.page-header {
  background: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
  padding: $spacing-4 $spacing-6;
  
  .page-title {
    font-size: $font-size-xl;
    font-weight: $font-weight-semibold;
    color: var(--text-color-primary);
    margin: 0;
  }
}

.page-content {
  padding: $spacing-6;
  flex: 1;
}

// 卡片样式
.card {
  background: var(--bg-color);
  border-radius: $border-radius-lg;
  box-shadow: $shadow-sm;
  border: 1px solid var(--border-color);
  overflow: hidden;
  
  .card-header {
    padding: $spacing-4 $spacing-6;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color-secondary);
    
    .card-title {
      font-size: $font-size-lg;
      font-weight: $font-weight-medium;
      margin: 0;
      color: var(--text-color-primary);
    }
  }
  
  .card-body {
    padding: $spacing-6;
  }
  
  .card-footer {
    padding: $spacing-4 $spacing-6;
    border-top: 1px solid var(--border-color);
    background: var(--bg-color-secondary);
  }
}

// 按钮样式
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: $spacing-2 $spacing-4;
  font-size: $font-size-sm;
  font-weight: $font-weight-medium;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: $border-radius-md;
  cursor: pointer;
  transition: $transition-base;
  user-select: none;
  
  &:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
  }
  
  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }
  
  // 主要按钮
  &.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    
    &:hover:not(:disabled) {
      background-color: var(--primary-color);
      opacity: 0.9;
    }
  }
  
  // 次要按钮
  &.btn-secondary {
    background-color: transparent;
    color: var(--text-color-primary);
    border-color: var(--border-color);
    
    &:hover:not(:disabled) {
      background-color: var(--bg-color-secondary);
    }
  }
  
  // 成功按钮
  &.btn-success {
    background-color: var(--success-color);
    color: white;
    border-color: var(--success-color);
    
    &:hover:not(:disabled) {
      opacity: 0.9;
    }
  }
  
  // 危险按钮
  &.btn-danger {
    background-color: var(--error-color);
    color: white;
    border-color: var(--error-color);
    
    &:hover:not(:disabled) {
      opacity: 0.9;
    }
  }
  
  // 按钮尺寸
  &.btn-sm {
    padding: $spacing-1 $spacing-3;
    font-size: $font-size-xs;
  }
  
  &.btn-lg {
    padding: $spacing-3 $spacing-6;
    font-size: $font-size-base;
  }
}

// 表单样式
.form-group {
  margin-bottom: $spacing-4;
  
  .form-label {
    display: block;
    margin-bottom: $spacing-2;
    font-size: $font-size-sm;
    font-weight: $font-weight-medium;
    color: var(--text-color-primary);
  }
  
  .form-control {
    width: 100%;
    padding: $spacing-2 $spacing-3;
    font-size: $font-size-sm;
    border: 1px solid var(--border-color);
    border-radius: $border-radius-md;
    background-color: var(--bg-color);
    color: var(--text-color-primary);
    transition: $transition-base;
    
    &:focus {
      border-color: var(--primary-color);
      box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
      outline: none;
    }
    
    &::placeholder {
      color: var(--text-color-placeholder);
    }
    
    &:disabled {
      background-color: var(--bg-color-secondary);
      opacity: 0.6;
    }
  }
  
  .form-error {
    margin-top: $spacing-1;
    font-size: $font-size-xs;
    color: var(--error-color);
  }
}

// 表格样式
.table-container {
  background: var(--bg-color);
  border-radius: $border-radius-lg;
  overflow: hidden;
  box-shadow: $shadow-sm;
  border: 1px solid var(--border-color);
}

.table {
  width: 100%;
  border-collapse: collapse;
  
  th,
  td {
    padding: $spacing-3 $spacing-4;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
  }
  
  th {
    background-color: var(--bg-color-secondary);
    font-weight: $font-weight-semibold;
    color: var(--text-color-primary);
    font-size: $font-size-sm;
  }
  
  td {
    color: var(--text-color-primary);
    font-size: $font-size-sm;
  }
  
  tr:last-child td {
    border-bottom: none;
  }
  
  tr:hover {
    background-color: var(--bg-color-secondary);
  }
}

// 导航样式
.nav {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0;
  
  .nav-item {
    .nav-link {
      display: block;
      padding: $spacing-2 $spacing-4;
      text-decoration: none;
      color: var(--text-color-secondary);
      transition: $transition-base;
      
      &:hover {
        color: var(--text-color-primary);
      }
      
      &.active {
        color: var(--primary-color);
        font-weight: $font-weight-medium;
      }
    }
  }
}

// 徽章样式
.badge {
  display: inline-flex;
  align-items: center;
  padding: $spacing-1 $spacing-2;
  font-size: $font-size-xs;
  font-weight: $font-weight-medium;
  line-height: 1;
  border-radius: $border-radius-full;
  
  &.badge-primary {
    background-color: var(--primary-color);
    color: white;
  }
  
  &.badge-success {
    background-color: var(--success-color);
    color: white;
  }
  
  &.badge-warning {
    background-color: var(--warning-color);
    color: white;
  }
  
  &.badge-danger {
    background-color: var(--error-color);
    color: white;
  }
  
  &.badge-secondary {
    background-color: var(--secondary-color);
    color: white;
  }
}

// 工具提示
.tooltip {
  position: relative;
  display: inline-block;
  
  .tooltip-text {
    visibility: hidden;
    width: max-content;
    max-width: 200px;
    background-color: var(--gray-900);
    color: white;
    text-align: center;
    border-radius: $border-radius-md;
    padding: $spacing-2 $spacing-3;
    position: absolute;
    z-index: $z-index-tooltip;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: $font-size-xs;
    
    &::after {
      content: "";
      position: absolute;
      top: 100%;
      left: 50%;
      margin-left: -5px;
      border-width: 5px;
      border-style: solid;
      border-color: var(--gray-900) transparent transparent transparent;
    }
  }
  
  &:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
  }
}

// 加载状态
.loading {
  @include flex-center;
  padding: $spacing-8;
  
  .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

// 空状态
.empty-state {
  @include flex-center;
  flex-direction: column;
  padding: $spacing-8;
  text-align: center;
  
  .empty-icon {
    font-size: 48px;
    color: var(--text-color-placeholder);
    margin-bottom: $spacing-4;
  }
  
  .empty-title {
    font-size: $font-size-lg;
    font-weight: $font-weight-medium;
    color: var(--text-color-primary);
    margin-bottom: $spacing-2;
  }
  
  .empty-description {
    font-size: $font-size-sm;
    color: var(--text-color-secondary);
    margin-bottom: $spacing-4;
  }
} 